<!--MSTP,SDH非正常变更要求完成日期变更-->
<script>
import Common from "@/mixins/order/commonbg.js";
import OrderService from "@/api/order/OrderService.js";
import PPMForm from "@/crm3.0part7-ppm/core/ppmForm.vue";
export default {
  name: "mstp10460033",
  mixins: [PPMForm, Common],
  data() {
    return {
      //MSTP	SDH	非正常变更	要求完成日期变更
      // proName: 'MSTP'
      orderDay: '',
      startDate:{
        disabledDate(time) {
          return time.getTime() < Date.now() - 3600 * 1000 * 24 * 1;//限制初始日期
        }
      }
    };
  },
  async mounted() {
        let OldOrderInfo = await this.initCommon();
        let orderItems = OldOrderInfo.orderItems;
        let lastStateCd = JSON.parse(
            sessionStorage.getItem("changeRow")
         ).lastStateCd;
         var orderDay;
         if(lastStateCd=="50030002"){
             orderItems.forEach((item) => {
               if (item.mainOrderItemFlag == "1") {
                  orderDay=item.reqOrderDate;
               }
            });
         }else{
            orderItems.forEach((item) => {
                   if (item.mainOrderItemFlag == "1") {
                      orderDay=item.orderDate;
                   }
                });
         }
        //  if(orderDay){
        //          orderDay = this.$util.dateFormat(
        //           new Date(),
        //           "yyyy-MM-dd"
        //         );
        //  }
        this.orderDay=orderDay;
        this.formData['10460305-100010082'].value = orderDay
  },

  computed: {},
  methods: {
     orderDate() {
          if(this.orderDay && new Date(this.formData["10460305-100010082"].value).getTime() > new Date(this.orderDay).getTime()){
            this.formData["10460305-142000998"].disabled = false;
            //this.SetRequired("1", "10460305-142000998");//延迟单类型必填
            this.SetRequired({ attrName:'延迟单类型', formkey:'10460305-142000998', reqName:'empty', reqStatus:true});
            this.formData["10460305-142000998"].value="142998001";
          }else{
            //this.SetRequired("0", "10460305-142000998");
            this.SetRequired({ attrName:'', formkey:'10460305-142000998', reqName:'empty', reqStatus:false});
            this.formData["10460305-142000998"].value="";
            this.formData["10460305-142000998"].disabled = true;
          }
    },
    StartDate() {
      // if(key == '10460460-100012033'){
        return this.startDate;
      // }
    },

  },
};
</script>